package com.bolt.auth.admin.api.sys.entity;

import com.bolt.support.spring.jpa.entity.BaseUuidEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.time.LocalDateTime;


@Access(AccessType.FIELD)
@Entity
@Table(name = "SYS_USER_LOGON_LOG")
@Cache(usage = CacheConcurrencyStrategy.NONE)
@Data
public class LoginLogEntity extends BaseUuidEntity {

    @ManyToOne
    @JoinColumn(name = "user_id")
    private UserEntity user;

    @Column(name = "LOGON_YEAR_MONTH_DAY", nullable = true)
    private String logonYearMonthDay;

    @Column(name = "LOGON_TIME")
    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss",locale = "GMT+8")
    private LocalDateTime logonTime;

    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss",locale = "GMT+8")
    @Column(name = "LOGOUT_TIME")
    private LocalDateTime logoutTime;

    @Column(name = "LOGON_TIME_LENGTH")
    private Long logonTimeLength;

    @Column(name = "LOGON_TIMES")
    private Long logonTimes;

    @Column(name = "USER_AGENT")
    private String userAgent;

    @Column(name = "XFORWARD_FOR")

    private String xforwardFor;

    @Column(name = "LOCAL_ADDR")
    private String localAddr;

    @Column(name = "LOCAL_NAME")
    private String localName;

    @Column(name = "LOCAL_PORT")
    private Integer localPort;

    @Column(name = "REMOTE_ADDR")
    private String remoteAddr;

    @Column(name = "REMOTE_HOST")
    private String remoteHost;

    @Column(name = "REMOTE_PORT")
    private Integer remotePort;


    private String serverIP;

    @Column(name = "HTTP_SESSION_ID", length = 128, unique = true)
    private String httpSessionId;


}